#include "Lighting.glsl";

attribute vec4 a_Position;

attribute vec2 a_Texcoord0;
varying vec2 v_Texcoord0;

uniform mat4 u_WorldMat;
uniform mat4 u_MvpMatrix;

attribute vec3 a_Normal;
varying vec3 v_Normal; 

uniform vec3 u_CameraPos;
varying vec3 v_ViewDir; 

void main()
{
	vec4 position=a_Position;

	mat4 worldMat = u_WorldMat;
	vec3 positionWS=(worldMat*position).xyz;
	v_ViewDir = u_CameraPos-positionWS;
	mat3 worldInvMat = INVERSE_MAT(mat3(worldMat));
	v_Normal=normalize(a_Normal*worldInvMat);

    gl_Position = u_MvpMatrix * position;
	gl_Position=remapGLPositionZ(gl_Position);
	v_Texcoord0 = a_Texcoord0;
}